package com.kun.portal.webframe.util;

import com.kun.portal.webframe.po.AppointmentPo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MessageFilter {
    public static HashMap<String,HashMap<String,Boolean>> messageFilter = new HashMap <String,HashMap<String,Boolean>>();
    public static  class MessageType{
        public static String transFormToFlightPlane="TRANSFORM_TO_FLIGHT_PLANE";//转换成预约航班计划预计划
        public static String addAppointment = "ADD_APPOINTMENT";//提交预约
        public static String throughAudit = "THROUGH_AUDIT";//审核通过
        public static String  CourseNodeCompleted = "COURSE_NODE_COMPLETED";//进程节点提交
        public static String editAppointment="EDIT_APPOINTMENT";//修改预约信息
        public static String passAppointment="PASS_APPOINTMENT";//取消预约信息
        public static String prePlaneEdit="PRE_PLANE_EDIT";//预约航班计划预计划修改
        public static String prePlanePublish="PRE_PLANE_PUBLISH";//预约航班计划预计划发布
        public static String appoFlightPlaneEdit="APPO_FLIGHT_PLANE_EDIT";//预约航班计划修改
        public static String processStatusChange="PROCESS_STATUS_CHANGE";//预约航班计划修改


    }
    public static class Module{
        public static String prePlane ="PRE_PLANE"; //预约航班计划预计划
        public static String reservationAudit ="RESERVATION_AUDIT"; //预约审核
        public static String processControl  ="PROCESS_CONTROL";//进程监控
        public static String appoFlightPlane ="APPO_FLIGHT_PLANE";//预约航班信息
    }
    static {
        HashMap<String,Boolean>  prePlane=new HashMap<String,Boolean>();
        prePlane.put(MessageType.addAppointment,true);
        prePlane.put(MessageType.throughAudit,true);
        prePlane.put(MessageType.editAppointment,true);
        prePlane.put(MessageType.passAppointment,true);
        messageFilter.put(Module.prePlane,prePlane);

        HashMap<String,Boolean>  reservationAudit=new HashMap<String,Boolean>();
        reservationAudit.put(MessageType.transFormToFlightPlane,true);
        reservationAudit.put(MessageType.prePlaneEdit,true);
        messageFilter.put(Module.reservationAudit,reservationAudit);

        HashMap<String,Boolean>  processControl=new HashMap<String,Boolean>();
        processControl.put(MessageType.CourseNodeCompleted,true);
        processControl.put(MessageType.processStatusChange,true);
        messageFilter.put(Module.processControl,processControl);
/*预约航班信息页面接受消息类型*/
        HashMap<String,Boolean>  appoFlightPlane=new HashMap<String,Boolean>();
        appoFlightPlane.put(MessageType.prePlaneEdit,true);
        appoFlightPlane.put(MessageType.prePlanePublish,true);
        appoFlightPlane.put(MessageType.appoFlightPlaneEdit,true);
        messageFilter.put(Module.appoFlightPlane,appoFlightPlane);
    }
    public static List <String> getMessageType(String type){
      List<String> list = new ArrayList<>();
      for(String key :messageFilter.keySet()){
          if(messageFilter.get(key).get(type)!=null){
              list.add(key);
          }
      }
      return list;
    };

    public static List <String> getMessageTypeByModule(String type){
        List<String> list = new ArrayList<>();
        HashMap<String,Boolean>  map = messageFilter.get(type);
        if(map!=null){
            list = new ArrayList<>(map.keySet());
        }
        return list;
    };
}
